package com.t235.gc.order.controller;

import com.t235.gc.AjaxResult;
import com.t235.gc.entity.HomeRecyclingDetailOrder;
import com.t235.gc.entity.HomeRecyclingOrder;
import com.t235.gc.order.service.HomeRecyclingOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class HomeRecyclingOrderController {
    @Autowired
    private HomeRecyclingOrderService homeRecyclingOrderService;
    //根据orderStatus查询当前用户订单
    @GetMapping("/selectOrderByOrderStatus")
    public AjaxResult selectYuyue(Long userId, int orderStatus){
        List<HomeRecyclingOrder> list=homeRecyclingOrderService.selectOrderByOrderStatus(userId,orderStatus);
        return AjaxResult.success(list);
    }
    //根据订单ID查询订单详情
    @GetMapping("/selectOrderByOrderId")
    public AjaxResult selectOrderByOrderId(String orderId){
        List<HomeRecyclingDetailOrder> list=homeRecyclingOrderService.selectOrderByOrderId(orderId);
        return AjaxResult.success(list);
    }
    //取消订单
    @GetMapping("/updateOrderStatus")
    public AjaxResult updateOrderStatus(String orderId, int orderStatus){
        int num=homeRecyclingOrderService.updateOrderStatus(orderId,orderStatus);
        return AjaxResult.success(num);
    }
    //删除订单,删除状态由1变2
    @GetMapping("/delOrder")
    public AjaxResult delOrder(String orderId){
        homeRecyclingOrderService.delHomeRecyclingOrder(orderId);
        return AjaxResult.success();
    }

}
